In [1]:
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
In [2]:
np.random.seed(sum(map(ord, "aesthetics")))
In [3]:
def sinplot(flip=1):
x = np.linspace(0, 14, 100)
for i in range(1, 7):
plt.plot(x, np.sin(x + i * .5) * (7 - i) * flip)
In [4]:
sinplot()
In [5]:
import seaborn as sns
sinplot()
In [6]:
sns.set_style("whitegrid")
data = np.random.normal(size=(20, 6))
sns.boxplot(data=data);
In [7]:
sns.set_style("whitegrid")
data = np.random.normal(size=(20, 6)) + np.arange(6) / 2
sns.boxplot(data=data);
In [8]:
sns.set_style('dark')
sinplot()
In [11]:
sns.set_style("white")
sinplot()
In [12]:
sns.set_style("ticks")
sinplot()
In [13]:
sinplot()
sns.despine()
In [14]:
f, ax = plt.subplots()
sns.violinplot(data=data)
sns.despine(offset=10);
In [15]:
f, ax = plt.subplots()
sns.violinplot(data=data)
sns.despine(offset=10, trim=True);
sns.set_style("whitegrid") sns.boxplot(data=data, palette="deep") sns.despine(left=True)
In [9]:
with sns.axes_style("darkgrid"):
plt.subplot(211)
sinplot()
plt.subplot(212)
sinplot(-1)
In [19]:
sns.axes_style()
Out[19]:
In [10]:
sns.set_style("darkgrid", {"axes.facecolor": ".9"})
sinplot()
In [11]:
sns.set_style("darkgrid", {"axes.facecolor": ".96"})
sinplot()
In [12]:
# reset default parameters
sns.set()
sinplot()
In [13]:
sns.set_context("paper")
plt.figure(figsize=(8, 6))
sinplot()
In [14]:
sns.set_context("talk")
plt.figure(figsize=(8, 6))
sinplot()
In [28]:
sns.set_context("talk")
plt.figure(figsize=(8, 6))
sinplot()
In [32]:
sns.set_context("notebook", font_scale=1.5, rc={"lines.linewidth": 2.5})
sinplot()
In [35]:
sns.set(rc={"figure.figsize": (6, 6)})
np.random.seed(sum(map(ord, "palettes")))
In [39]:
print np.random.seed()
In [40]:
current_palette = sns.color_palette()
sns.palplot(current_palette)
In [41]:
sns.palplot(sns.color_palette("hls", 8))
In [49]:
sns.palplot(sns.hls_palette(8, l=.3, s=.8))
sns.palplot(sns.hls_palette(8, l=.7, s=.8))
sns.palplot(sns.hls_palette(8, l=.3, s=.3))
sns.palplot(sns.hls_palette(8, l=.7, s=.3))
sns.palplot(sns.hls_palette(8, l=.6, s=.9))
In [52]:
sns.palplot(sns.color_palette("husl", 8))
In [53]:
sns.palplot(sns.color_palette("Paired"))
In [54]:
sns.palplot(sns.color_palette("Set2", 10))
In [58]:
# data_type : {‘sequential’, ‘diverging’, ‘qualitative’}
sns.choose_colorbrewer_palette('qualitative', 0)
Out[58]:
In [59]:
flatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71"]
sns.palplot(sns.color_palette(flatui))
xkcd ran a crowdsourced effort to name random
This produced a set of 954 named colors,
which you can now reference in seaborn using the xkcd_rgb dictionary:
In [60]:
plt.plot([0, 1], [0, 1], sns.xkcd_rgb["pale red"], lw=3)
plt.plot([0, 1], [0, 2], sns.xkcd_rgb["medium green"], lw=3)
plt.plot([0, 1], [0, 3], sns.xkcd_rgb["denim blue"], lw=3);
In [61]:
colors = ["windows blue", "amber", "greyish", "faded green", "dusty purple"]
sns.palplot(sns.xkcd_palette(colors))
In [65]:
sns.palplot(sns.color_palette("Blues"))
sns.palplot(sns.color_palette("BuGn_r"))
sns.palplot(sns.color_palette("GnBu_r"))
sns.palplot(sns.color_palette("GnBu_d"))
In [66]:
sns.palplot(sns.color_palette("cubehelix", 8))
In [67]:
sns.palplot(sns.cubehelix_palette(8))
sns.palplot(sns.cubehelix_palette(8, start=.5, rot=-.75))
sns.palplot(sns.cubehelix_palette(8, start=2, rot=0, dark=0, light=.95, reverse=True))
In [69]:
x, y = np.random.multivariate_normal([0, 0], [[1, -.5], [-.5, 1]], size=300).T
cmap = sns.cubehelix_palette(light=1, as_cmap=True)
sns.kdeplot(x, y, cmap=cmap, shade=True)
Out[69]:
In [72]:
x, y = np.random.multivariate_normal([0, 0], [[1, -.5], [-.5, 1]], size=300).T
cmap = sns.cubehelix_palette(light=1, as_cmap=True)
sns.kdeplot(x, y, cmap=cmap)
Out[72]:
In [73]:
sns.palplot(sns.light_palette("green"))
sns.palplot(sns.dark_palette("purple"))
sns.palplot(sns.light_palette("navy", reverse=True))
In [74]:
pal = sns.dark_palette("palegreen", as_cmap=True)
sns.kdeplot(x, y, cmap=pal);
In [75]:
sns.palplot(sns.light_palette((210, 90, 60), input="husl"))
sns.palplot(sns.dark_palette("muted purple", input="xkcd"))
In [77]:
sns.palplot(sns.color_palette("BrBG", 7))
sns.palplot(sns.color_palette("RdBu_r", 7))
sns.palplot(sns.color_palette("coolwarm", 7))
In [78]:
sns.palplot(sns.diverging_palette(220, 20, n=7))
sns.palplot(sns.diverging_palette(145, 280, s=85, l=25, n=7))
sns.palplot(sns.diverging_palette(10, 220, sep=80, n=7))
sns.palplot(sns.diverging_palette(255, 133, l=60, n=7, center="dark"))
In [79]:
sns.set_palette("husl")
sinplot()
In [81]:
with sns.color_palette("PuBuGn_d"):
sinplot()
In [82]:
sinplot()
In [83]:
print np.random.seed(sum(map(ord, "distributions")))
In [87]:
print sum(map(ord, "distributions"))
In [88]:
print map(ord, "distributions")
In [91]:
print ord('d')
In [92]:
help(ord)
In [ ]: